﻿@inherits AdminCompontentBase
@page "/webHook"
<PageTitle>@T("WebHook")</PageTitle>
<AutoHeight Overflow>
    <HeaderContent>
        <div class="ma-0 search-panel my-6">
            <div class="d-flex justify-center search-panel-right full-width">
                <DefaultPageTitle>@T("WebHook")</DefaultPageTitle>
                <MSpacer></MSpacer>
                <SSearch @bind-Value="_queryParam.Filter" BackgroundColor="white" OnEnter="RefreshAsync" OnClearClick="HandleClearAsync" />
                <SButton Small BorderRadiusClass="rounded-lg" Class="ml-6" OnClick="()=> _upsertModal?.OpenModalAsync()!">@T("Permission.Add")</SButton>
            </div>
        </div>
    </HeaderContent>
    <AutoHeightContent>
        <MRow NoGutters Style="height:0;">
            @if (!_showEmptyPlaceholder)
            {
                @foreach (var _entitie in _entities.Result)
                {
                    <MCol Md="3" Class="pa-2">
                        <WebHookCard WebHook="_entitie" OnEdit="()=> _upsertModal?.OpenModalAsync(_entitie)!" OnTest="()=> _testModal?.OpenModalAsync(_entitie.Id)!" />
                    </MCol>
                }
            }
            else
            {
                <SEmptyPlaceholder Height="calc(100vh - 210px);" />
            }
        </MRow>
    </AutoHeightContent>
    <FooterContent>
        @if (!_showEmptyPlaceholder)
        {
            <SPagination Class="mt-6 rounded-2 pa-0" Page="@_queryParam.Page" PageSize="@_queryParam.PageSize" Total="_entities.Total" PageChanged="HandlePageChanged" PageSizeChanged="HandlePageSizeChanged" />
        }
    </FooterContent>
</AutoHeight>

<WebHookUpsertModal @ref="_upsertModal" OnOk="HandleOk" />
<WebHookTestModal @ref="_testModal" OnOk="HandleOk" />